package com.kws.payment.controller;

import cn.hutool.json.JSONUtil;
import com.kws.common.core.domain.R;
import com.kws.payment.dao.CreateUnionPayMiniOrderRq;
import com.kws.payment.dao.info.CreateAppUnionPayOrderInfo;
import com.kws.payment.dao.info.CreateWXUnionPayOrderInfo;
import com.kws.payment.service.UnionPayMiniService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.SneakyThrows;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * <b>UnionPayMiniController</b>
 *
 * @description: UnionPayMiniController <br>
 * @date: 2024/12/26 16:16 <br>
 * @author: lhm <br>
 * @version: 1.0 <br>
 */

@Api(tags = "银联支付-小程序支付")
@RestController
public class UnionPayMiniController {
    private static final Logger logger = LoggerFactory.getLogger(UnionPayMiniController.class);

    @Autowired
    private UnionPayMiniService unionPayMiniService;

    @SneakyThrows
    @ApiOperation("创建微信小程序支付订单")
    @PostMapping("/create/mini/unionPayOrder")
    public R<CreateWXUnionPayOrderInfo> createMiniUnionPayOrder(@RequestBody CreateUnionPayMiniOrderRq rq){
        logger.info("创建小程序微信支付下单入参:{}"+ JSONUtil.parse(rq));
        CreateWXUnionPayOrderInfo info = unionPayMiniService.createMiniUnionPayOrder(rq);
        return R.ok(info);
    }

}
